﻿#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int strStr(char* haystack, char* needle) {
    int len = strlen(haystack);
    int len2 = strlen(needle);
    for(int i = 0; i < len - len2 + 1; i++){
        int j = 0;
        for(; j < len2; j++){
            if(haystack[i + j] != needle[j])
                break;
        }
        if(j >= len2)
            return i;
    }
    return -1;
}

int main() {
    char haystack[] = "sad", needle[] = "sad";
    int position = strStr(haystack, needle);
    printf("The sub str local --- %d \n", position);
    return 0;
}